import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:yt_devops/components/gaps.dart';
import 'package:yt_devops/components/log_utils.dart';
import 'package:yt_devops/components/yt_text_style.dart';
import 'package:yt_devops/components/my_gesture_detector.dart';
import 'package:yt_devops/styles/styles.dart';

/**
 *
 * @Description TODO
 * @Author liuer
 * @CreateTime 2024年05月17日 09:28
 */
class EssTabWidget extends StatelessWidget {
  int selectedIndex;
  String firstTitle;
  String secondTitle;
  final Function(int) callBack;
  final Color textColor;
  final Color unSelectedTextColor;
  EssTabWidget(this.selectedIndex,this.callBack,{ required this.firstTitle,
     required this.secondTitle,this.textColor = Colour.primaryColor,
    this.unSelectedTextColor = Colour.mainTextColor,
    super.key});

  @override
  Widget build(BuildContext context) {
    Log.d('EssTabWidget=');
    return Container(
      padding: EdgeInsets.only(left: 16.w),
      margin: EdgeInsets.only(left: 16,right: 16),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(8),
        color: Colors.white,
      ),
      height: 44,
        alignment: Alignment.centerLeft,

      child: Row(
        children: [
          MyGestureDetector(onTap: () {

            selectedIndex = 0;
            callBack(selectedIndex);

          }, child: Text(
            firstTitle,
            style: ytTextStyle(
                fontSize: 16,
                fontWeight: selectedIndex == 0
                    ?FontWeight.w500:FontWeight.normal,
                color: selectedIndex == 0
                    ? textColor
                    : unSelectedTextColor),
          )),
          Gaps.hGap24,
          MyGestureDetector(onTap: () {
            selectedIndex = 1;
            callBack(selectedIndex);
          }, child: Text(
            secondTitle,
            style: ytTextStyle(
                fontSize: 16,
                fontWeight: selectedIndex == 1?FontWeight.w500:FontWeight.normal,
                color: selectedIndex == 1
                    ? textColor
                    : unSelectedTextColor),
          )),
        ],
      ),
    );
  }
}

